<template>
  <div class="flex flex_column">
    <!--彩稿订单 -->
    <el-dialog
      append-to-body
      title="选择订单"
      :visible.sync="isVisible"
      :close-on-click-modal="false"
      custom-class="bodyNoPadDialog bigDialog"
      width="70%"
      @close="closeMarDialog"
      @open="openDialog"
    >
      <div class="dialogDody marDialog flex flex_column">
        <div class="btnCon flex flex_between" style="border-bottom: none">
          <!--      搜索框-->
          <div class="search">
            <el-input
              v-model="materalSearch.likeWords"
              prefix-icon="el-icon-search"
              placeholder="输入关键字"
              size="small"
              @keyup.enter.native="MarterdialogShow"
            >
            </el-input>
          </div>
        </div>
        <!-- 表格区域       -->
        <div class="tableCon not pt0" style="padding: 16px">
          <el-table
            :data="materialList"
            border
            style="width: 100%"
            height="600"
            v-loading="marLoading"
            @row-dblclick="saveColorManuscript"
          >
            <el-table-column prop="orderNo" width="190" label="订单单号" />
            <el-table-column prop="xieYiShuHao" width="190" label="协议书号" />
            <el-table-column prop="orderTypeName" width="150" show-overflow-tooltip label="订单类型" />
            <el-table-column prop="produceTaskBillingState" label="订单状态" width="150"  show-overflow-tooltip>
              <template slot-scope="{ row }">
                {{ row.produceTaskBillingState == 0 ?'待开':'停工' }}
              </template>
            </el-table-column>
            <el-table-column prop="customerName" width="150" show-overflow-tooltip label="客户名称" />
            <el-table-column prop="productCode" width="150" show-overflow-tooltip label="产品编号" />
            <el-table-column
              prop="orderProductName"
              width="150"
              show-overflow-tooltip
              label="产品名称"
            />
            <el-table-column prop="printingSurface" label="版面" />
            <el-table-column prop="productVersions" label="版本" />
            <el-table-column prop="productUnion" label="单位" />
            <el-table-column prop="orderNum" label="订单数量" />
            <el-table-column prop="tagSumQuantity" label="标签枚数" />
            <el-table-column prop="arriveDataQuantity" label="数据下达" />
            <el-table-column prop="stockNum" label="库存数量" />
            <el-table-column prop="expectedDeliveryTime" label="交货日期" width="150"  show-overflow-tooltip>
              <template slot-scope="{ row }">
                {{ parseTime(row.expectedDeliveryTime, "{y}-{m}-{d}") }}
              </template>
            </el-table-column>
            <el-table-column
              width="105"
              prop="deliveryDays"
              label="交货剩余天数"
            />
            <el-table-column
              width="150"
              show-overflow-tooltip
              prop="salesmanName"
              label="业务员"
            />
            <el-table-column prop="orderCreateTime" label="开单时间" width="180" show-overflow-tooltip />
            <el-table-column prop="createOrderPerson" label="开单人员" />
          </el-table>
          <div class="d_pag">
            <pagination
              :total="total || 0"
              :page.sync="materalSearch.pageIndex"
              :limit.sync="materalSearch.pageSize"
              @pagination="MarterdialogShow"
            />
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
  <script>
import { parseTime } from "@/utils";
import Pagination from "@/components/Pagination"
export default {
  name: "orderList",
  props: {
    perVisible: {
      type: Boolean,
      required: false,
    },
  },
  components: { Pagination },
  data() {
    return {
      materialList: [], // 订单列表
      templateSelection: {},
      materalSearch: {
        pageIndex: 1,
        pageSize: 30,
        queryDataBaseFiled: "",
        likeWords: "",
        orderType: "",
        customerCode: "",
        orderState: 0,
        produceState: 0,
        financeState: 0,
        deliveryState: 0,
        queryCondition: 0,
      }, // 彩稿列表明细搜索条件
      marLoading: false,
      addLoading: false,
      loading: false,
      total:'',
    };
  },
  computed: {
    isVisible: {
      get() {
        return this.perVisible;
      },
      set(val) {
        this.$emit("update:perVisible", val);
      },
    },
  },
  created() {
    // this.MarterdialogShow()
  },
  mounted() {},
  methods: {
    parseTime(time, cFormat) {
      return parseTime(time, cFormat);
    },
    openDialog() {
      this.openDialog.likeWords = "";
      this.MarterdialogShow();
    },
    getCurrentRow(row) {
      // 获取选中数据   row表示选中这一行的数据，可以从里面提取所需要的值
      this.templateSelection = row;
    },

    // 关闭彩稿订单
    closeMarDialog() {
      this.isVisible = false;
      this.materalSearch.likeWords = ''
    },
    // 协议书号查找
    MarterdialogShow() {
      const parmas = this.materalSearch;
      this.marLoading = true;
      this.$api.product
        .GetPageSaleOrdersByPassingColorDraft(parmas)
        .then((res) => {
          this.materialList = res.list;
          this.total = res.totalCount
          this.marLoading = false;
        })
        .catch(() => {});
    },

    saveColorManuscript(row) {
      
      this.$emit("current", row);
      this.isVisible = false;
    },
  },
};
</script>
  <style lang="scss" scoped>
</style>
  